package com.amex.uam.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.amex.uam.dao.UserDao;
import com.amex.uam.model.AMEX_BUSINESS;
import com.amex.uam.model.AMEX_UNIT;
import com.amex.uam.model.MS_USER_ADMIN;
import com.amex.uam.model.MS_USER_CTRY_ACSS;
import com.amex.uam.model.MS_USER_PROJ;
import com.amex.uam.model.MS_USER_RGN_ACSS;
import com.amex.uam.model.MS_USER_SEC_GRP;
import com.amex.uam.model.USER_DEPT;

@Repository("userDao") //@Reposityused for dao Injection
//<bean id="userDao" class="..."></bean>
public class UserDaoImpl extends JdbcDao implements UserDao {
	
	/* get user by amexWebId */
	public MS_USER_ADMIN loadUserByAmexWebId(String amexWebId) {
		String sql = "select * from MS_USER_ADMIN where WORKFORCE_MBR_ID = ?";
		Object[] params = {amexWebId};
		 List<MS_USER_ADMIN> list = this.getJdbcTemplate().query(sql, params, ParameterizedBeanPropertyRowMapper.newInstance(MS_USER_ADMIN.class));
		 if (list!= null && !list.isEmpty()) {
			 return list.get(0);
		 }
		 return null;
	}
	
	
	
	@Override
	public boolean addUser(MS_USER_ADMIN user) {
		String sql = "INSERT INTO MS_USER_ADMIN ("
				+ "WORKFORCE_MBR_ID,"
				+ "USER_ADMIN_STA_CD,"
				+ "USER_GRP_ID,"
				+ "USER_STA_CD,"
				+ "USER_TYPE_CD,"
				+ "COST_CTR_CD,"
				+ "DEPT_ID,"
				+ "AMEX_BUS_CD,"
				+ "USER_ACSS_TYPE_CD,"
				+ "USER_ID,"
				+ "USER_1ST_NM,"
				+ "USER_MI_TX,"
				+ "USER_LST_NM," 
				+ "USER_EMAIL_AD_TX,"
				+ "USER_CMPL_PHONE_NO,"
				+ "WORKFORCE_MBR_MAN_1ST_NM,"
				+ "WORKFORCE_MBR_MAN_MI_TX,"
				+ "WORKFORCE_MBR_MAN_LST_NM,"
				+ "WORKFORCE_MBR_MAN_EMAIL_AD_TX,"
				+ "VP_NM,"
				+ "ACSS_RSN_TX,"
				+ "USER_ACSS_REJCT_RSN_TX,"
				+ "WORKFORCE_MBR_CLASS_CD,"
				+ "AMEX_UNIT_CD,"
				+ "LST_LOGIN_TS,"
				+ "CREAT_TS,"
				+ "LST_UPDT_TS,"
				+ "GEO_ACSS_LVL_CD,"
				+ "LIF_GLBL_ACS_IN,"
				+ "CLM_GLBL_ACS_IN,"
				+ "NDA_TS"
				+ ")"
				+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		
		Object[] params= {
				user.getWORKFORCE_MBR_ID(),
				user.getUSER_ADMIN_STA_CD(),
				user.getUSER_GRP_ID(),
				user.getUSER_STA_CD(),
				user.getUSER_TYPE_CD(),
				user.getCOST_CTR_CD(),
				user.getDEPT_ID(),
				user.getAMEX_BUS_CD(),
				user.getUSER_ACSS_TYPE_CD(),
				user.getUSER_ID(),
				user.getUSER_1ST_NM(),
				user.getUSER_MI_TX(),
				user.getUSER_LST_NM(), 
				user.getUSER_EMAIL_AD_TX(),
				user.getUSER_CMPL_PHONE_NO(),
				user.getWORKFORCE_MBR_MAN_1ST_NM(),
				user.getWORKFORCE_MBR_MAN_MI_TX(),
				user.getWORKFORCE_MBR_MAN_LST_NM(),
				user.getWORKFORCE_MBR_MAN_EMAIL_AD_TX(),
				user.getVP_NM(),
				user.getACSS_RSN_TX(),
				user.getUSER_ACSS_REJCT_RSN_TX(),
				user.getWORKFORCE_MBR_CLASS_CD(),
				user.getAMEX_UNIT_CD(),
				user.getLST_LOGIN_TS(),
				user.getCREAT_TS(),
				user.getLST_UPDT_TS(),
				user.getGEO_ACSS_LVL_CD(),
				user.getLIF_GLBL_ACS_IN(),
				user.getCLM_GLBL_ACS_IN(),
				user.getNDA_TS()
		};
		
		return this.getJdbcTemplate().update(sql, params) > 0;
	}
	
	@Override
	public boolean removeUser(String userId) {
		String sql = "DELETE FROM MS_USER_ADMIN WHERE USER_ID=?";
		this.getJdbcTemplate().update(sql, new Object[]{userId});
		return true;
	}
	
	@Override
	public List<Map<String, String>> searchUser(String searchParam, String searchDBFldString) {
		String sql = "select mua.WORKFORCE_MBR_ID, ud.DEPT_NM, mua.USER_ID, mua.USER_1ST_NM, "
				+ "mua.USER_LST_NM, mua.DEPT_ID, mua.AMEX_BUS_CD, mua.COST_CTR_CD, mua.USER_EMAIL_AD_TX, "
				+ "mua.WORKFORCE_MBR_MAN_1ST_NM, mua.WORKFORCE_MBR_MAN_LST_NM from MS_USER_ADMIN mua full outer join "
				+ "USER_DEPT ud on ud.DEPT_ID = mua.DEPT_ID where mua."+searchDBFldString+" = ?";
		System.out.println(sql);
		List<Map<String, String>> userRowsList = this.getJdbcTemplate().query(sql, new Object[]{searchParam}, new RowMapper<Map<String, String>>(){
			public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException{
				Map<String, String> userMap = new HashMap<String, String>();
				int columnCount = rs.getMetaData().getColumnCount();
				for(int i=1; i<columnCount+1; i++){
					String key = rs.getMetaData().getColumnName(i);
					String val = rs.getString(key);
					if(val==null || val.trim().equals("")){
						System.out.println(key);
						userMap.put(key, "N/A");
					}else{
						userMap.put(key, val.trim());
					}
					
				}
				return userMap;
			}
		});
		return userRowsList;
	}

	@Override
	public Map<String, String> loadUserProfile(String userId) {
		 String sql = 
			"SELECT	A.USER_STA_CD,A.USER_TYPE_CD,A.USER_ADMIN_STA_CD,A.USER_ACSS_TYPE_CD,A.WORKFORCE_MBR_ID,A.USER_1ST_NM, I.FUNC_GRP_ROLE_ID,"
			+ "	A.USER_MI_TX,A.USER_LST_NM,	A.DEPT_ID,A.AMEX_BUS_CD,A.COST_CTR_CD,A.USER_CMPL_PHONE_NO,	A.USER_EMAIL_AD_TX,"
			+ "	A.WORKFORCE_MBR_MAN_1ST_NM,	A.WORKFORCE_MBR_MAN_MI_TX,	A.WORKFORCE_MBR_MAN_LST_NM,	A.WORKFORCE_MBR_MAN_EMAIL_AD_TX,"
			+ "	A.VP_NM,A.ACSS_RSN_TX,	DAYS_BETWEEN(CURRENT_TIMESTAMP,A.NDA_TS)+1 as DAYS_DIFF,DATE(A.SEC_XCPT_END_DT) as SEC_XCPT_END_DT,"
			+ "	DATE(A.NDA_TS) as NDA_TS,	A.AMEX_UNIT_CD,	D.DEPT_NM,E.AMEX_BUS_DS_TX,	F.AMEX_UNIT_DS_TX,G.FUNC_GRP_ROLE_NM,	A.CLM_GLBL_ACS_IN,"
			+ "	A.LIF_GLBL_ACS_IN"
			+ " FROM	"
			+ "		MS_USER_ADMIN A,"
			+ "		USER_DEPT D,"
			+ "		AMEX_BUSINESS E,"
			+ "		AMEX_UNIT F, "
			+ "		MS_USER_FUNC_GRP_ROLE I, "
			+ "		FUNC_GRP_ROLE G"
			+ " WHERE	"
			+ "		A.WORKFORCE_MBR_ID= I.WORKFORCE_MBR_ID "
			+ "		AND A.USER_ID=? "
			+ "		AND	A.DEPT_ID=D.DEPT_ID "
			+ "		AND	A.AMEX_BUS_CD=E.AMEX_BUS_CD "
			+ "		AND	A.AMEX_UNIT_CD=F.AMEX_UNIT_CD "
			+ "		AND I.FUNC_GRP_ROLE_ID = G.FUNC_GRP_ROLE_ID";
		
		 sql = // For test on the SQLServer
			"SELECT	A.USER_STA_CD,A.USER_TYPE_CD,A.USER_ADMIN_STA_CD,A.USER_ACSS_TYPE_CD,A.WORKFORCE_MBR_ID,A.USER_1ST_NM, I.FUNC_GRP_ROLE_ID,"
			+ "	A.USER_MI_TX,A.USER_LST_NM,	A.DEPT_ID,A.AMEX_BUS_CD,A.COST_CTR_CD,A.USER_CMPL_PHONE_NO,	A.USER_EMAIL_AD_TX,"
			+ "	A.WORKFORCE_MBR_MAN_1ST_NM,	A.WORKFORCE_MBR_MAN_MI_TX,	A.WORKFORCE_MBR_MAN_LST_NM,	A.WORKFORCE_MBR_MAN_EMAIL_AD_TX,"
			+ "	A.VP_NM,A.ACSS_RSN_TX,DATEDIFF(DD,CURRENT_TIMESTAMP,A.NDA_TS) + 1 as DAYS_DIFF,A.SEC_XCPT_END_DT,"
			+ "	NDA_TS,	A.AMEX_UNIT_CD,	D.DEPT_NM,E.AMEX_BUS_DS_TX,	F.AMEX_UNIT_DS_TX,G.FUNC_GRP_ROLE_NM,	A.CLM_GLBL_ACS_IN,"
			+ "	A.LIF_GLBL_ACS_IN"
			+ " FROM	MS_USER_ADMIN A,USER_DEPT D,AMEX_BUSINESS E,	AMEX_UNIT F, MS_USER_FUNC_GRP_ROLE I, FUNC_GRP_ROLE G"
			+ " WHERE	A.WORKFORCE_MBR_ID= I.WORKFORCE_MBR_ID AND	"
			+ "	A.USER_ID=? AND	A.DEPT_ID=D.DEPT_ID AND	A.AMEX_BUS_CD=E.AMEX_BUS_CD AND	A.AMEX_UNIT_CD=F.AMEX_UNIT_CD AND"
			+ "	I.FUNC_GRP_ROLE_ID = G.FUNC_GRP_ROLE_ID";
		 
		 //System.out.println("loadUserProfile.SQL: " + sql);
		 //System.out.println("loadUserProfile.userId: " + userId);
		
		 // !!! Search returns more than one object sometimes, so returns the first object.
		 //Map<String, Object> userProfile = this.jdbcTemplate.queryForObject(sql, 
		 List<Map<String, String>> userList = this.getJdbcTemplate().query(sql, new Object[] { userId }, new SimpleRowMapper());

		return userList != null && userList.size() > 0 ? userList.get(0) : new HashMap<String, String>();
	}

	public List<MS_USER_SEC_GRP> loadUserSecurityGroup(String amexWebId){
		final String SQL = "select WORKFORCE_MBR_ID, SEC_GRP_NM, CREAT_TS, SEC_GRP_XCPT_IN from MS_USER_SEC_GRP where WORKFORCE_MBR_ID = ?";
		Object[] params = {amexWebId};
		return this.getJdbcTemplate().query(SQL, params, ParameterizedBeanPropertyRowMapper.newInstance(MS_USER_SEC_GRP.class));
	}

	@Override
	public List<MS_USER_CTRY_ACSS> loadGEOCTRYByAmexWebId(String amexWebId) {
		
		final String SQL = "select WORKFORCE_MBR_ID, CTRY_NM from MS_USER_CTRY_ACSS where WORKFORCE_MBR_ID = ?";
		Object[] params = {amexWebId};
		return this.getJdbcTemplate().query(SQL, params, ParameterizedBeanPropertyRowMapper.newInstance(MS_USER_CTRY_ACSS.class));
	}

	@Override
	public List<MS_USER_RGN_ACSS> loadGEORGNByAmexWebId(String amexWebId) {
		final String SQL = "select WORKFORCE_MBR_ID, RGN_ABBR_NM from MS_USER_RGN_ACSS where WORKFORCE_MBR_ID = ?";
		Object[] params = {amexWebId};
		return this.getJdbcTemplate().query(SQL, params, ParameterizedBeanPropertyRowMapper.newInstance(MS_USER_RGN_ACSS.class));
	}

	@Override
	public int updateVUPUSRGenInfo(MS_USER_ADMIN mua) {
		final String sql = "update MS_USER_ADMIN "
				+ "set DEPT_ID = ?, AMEX_BUS_CD = ?, USER_EMAIL_AD_TX = ?, WORKFORCE_MBR_MAN_1ST_NM = ?, "
				+ "WORKFORCE_MBR_MAN_MI_TX = ?, WORKFORCE_MBR_MAN_LST_NM = ?, AMEX_UNIT_CD = ?, COST_CTR_CD = ?, "
				+ "USER_CMPL_PHONE_NO = ?, WORKFORCE_MBR_MAN_EMAIL_AD_TX = ?, VP_NM =?, ACSS_RSN_TX = ?, NDA_TS = ?"
				+ "where WORKFORCE_MBR_ID = ?";
		Object[] params= {mua.getDEPT_ID(), mua.getAMEX_BUS_CD(), mua.getUSER_EMAIL_AD_TX(),
				mua.getWORKFORCE_MBR_MAN_1ST_NM(), mua.getWORKFORCE_MBR_MAN_MI_TX(), mua.getWORKFORCE_MBR_MAN_LST_NM(),
				mua.getAMEX_UNIT_CD(), mua.getCOST_CTR_CD(), mua.getUSER_CMPL_PHONE_NO(), mua.getWORKFORCE_MBR_MAN_EMAIL_AD_TX(),
				mua.getVP_NM(), mua.getACSS_RSN_TX(), mua.getNDA_TS(), mua.getWORKFORCE_MBR_ID()};
		
		return this.getJdbcTemplate().update(sql, params);
	}

	@Override
	public int updateVUPUSRAmexBuss(AMEX_BUSINESS ab) {
		final String sql= "select AMEX_BUS_CD, AMEX_BUS_DS_TX from AMEX_BUSINESS where AMEX_BUS_CD = ?";
		int result = 0;
		Object[] params= {ab.getAMEX_BUS_CD()};
		List<AMEX_BUSINESS> list=this.getJdbcTemplate().query(sql, params, ParameterizedBeanPropertyRowMapper.newInstance(AMEX_BUSINESS.class));
		if(list==null || list.size()==0){
			final String insertSql= "insert into AMEX_BUSINESS(AMEX_BUS_CD, AMEX_BUS_DS_TX) values(?, ?)";
			Object[] insertParams={ab.getAMEX_BUS_CD(), ab.getAMEX_BUS_DS_TX()};
			result = this.getJdbcTemplate().update(insertSql, insertParams);
		}else{
			final String updateSql= "update AMEX_BUSINESS set AMEX_BUS_DS_TX = ? where AMEX_BUS_CD = ?";
			Object[] updateParams={ab.getAMEX_BUS_DS_TX(), ab.getAMEX_BUS_CD()};
			result = this.getJdbcTemplate().update(updateSql, updateParams);
		}
		
		return result;
	}

	@Override
	public int updateVUPUSRAmexUnit(AMEX_UNIT au) {
		final String sql= "select AMEX_UNIT_CD, AMEX_UNIT_DS_TX from AMEX_UNIT where AMEX_UNIT_CD = ?";
		int result = 0;
		Object[] params= {au.getAMEX_UNIT_CD()};
		List<AMEX_UNIT> list=this.getJdbcTemplate().query(sql, params, ParameterizedBeanPropertyRowMapper.newInstance(AMEX_UNIT.class));
		if(list==null || list.size()==0){
			final String insertSql= "insert into AMEX_UNIT(AMEX_UNIT_CD, AMEX_UNIT_DS_TX) values(?, ?)";
			Object[] insertParams={au.getAMEX_UNIT_CD(), au.getAMEX_UNIT_DS_TX()};
			result = this.getJdbcTemplate().update(insertSql, insertParams);
		}else{
			final String updateSql= "update AMEX_UNIT set AMEX_UNIT_DS_TX = ? where AMEX_UNIT_CD = ?";
			Object[] updateParams={au.getAMEX_UNIT_DS_TX(), au.getAMEX_UNIT_CD()};
			result = this.getJdbcTemplate().update(updateSql, updateParams);
		}
		
		return result;
	}
	
	@Override
	public boolean addMstrProd(List<MS_USER_PROJ> list) {
		final String insertSQL = "insert into MS_USER_PROJ(WORKFORCE_MBR_ID, MS_PROJ_ID, CREAT_TS) values(?,?,?)";
		if (list == null || list.isEmpty())
			return true;
		for (int i = 0; i < list.size(); i++) {
			MS_USER_PROJ prod = list.get(i);
			this.getJdbcTemplate().update(insertSQL, new Object[]{prod.getWORKFORCE_MBR_ID(), prod.getMS_PROJ_ID(), prod.getCREAT_TS()});
		}
		
		return true;
	}
	
	@Override
	public boolean updateVUPMSTRProd(List<MS_USER_PROJ> list) {
		
		final String deleteSQL = "delete from MS_USER_PROJ where WORKFORCE_MBR_ID=?";
		final String insertSQL = "insert into MS_USER_PROJ(WORKFORCE_MBR_ID, MS_PROJ_ID, CREAT_TS) values(?,?,?)"; 
		
		if (list == null && list.size() == 0) {
			return true;
		}
		String id = list.get(0).getWORKFORCE_MBR_ID();
		
		this.getJdbcTemplate().update(deleteSQL, new Object[]{id});
		
		for (int i = 0; i < list.size(); i++) {
			MS_USER_PROJ prod = list.get(i);
			this.getJdbcTemplate().update(insertSQL, new Object[]{prod.getWORKFORCE_MBR_ID(), prod.getMS_PROJ_ID(), prod.getCREAT_TS()});
		}
		
		return true;
	}
	
	
	@Override
	public boolean attachUserToGroup(String amexWebId, String groupName) {
		final String sql = "INSERT INTO MS_USER_SEC_GRP(WORKFORCE_MBR_ID,SEC_GRP_NM,CREAT_TS,SEC_GRP_XCPT_IN) VALUES(?,?,?,'N')";
		Object[] params = {amexWebId, groupName, new Timestamp(System.currentTimeMillis())};
		this.getJdbcTemplate().update(sql, params);
		return true;
	}
	
	@Override
	public boolean removeUserFromGroup(String amexWebId, String groupName) {
		final String sql = "DELETE FROM MS_USER_SEC_GRP WHERE WORKFORCE_MBR_ID=? and SEC_GRP_NM=?";
		this.getJdbcTemplate().update(sql, new Object[]{amexWebId, groupName});
		return true;
	}
	
	@Override
	public boolean updateCTRY(List<MS_USER_CTRY_ACSS> list) {
		final String deleteSQL = "delete from MS_USER_CTRY_ACSS where WORKFORCE_MBR_ID=?";
		final String insertSQL = "insert into MS_USER_CTRY_ACSS(WORKFORCE_MBR_ID, CTRY_NM, CREAT_TS) values(?,?,?)"; 
		
		if (list == null && list.size() == 0) {
			return false;
		}
		String id = list.get(0).getWORKFORCE_MBR_ID();
		
		this.getJdbcTemplate().update(deleteSQL, new Object[]{id});
		
		for (int i = 0; i < list.size(); i++) {
			MS_USER_CTRY_ACSS ctry = list.get(i);
			this.getJdbcTemplate().update(insertSQL, new Object[]{ctry.getWORKFORCE_MBR_ID(), ctry.getCTRY_NM(), ctry.getCREAT_TS()});
		}
		
		return true;
	}
	@Override
	public boolean updateRGN(List<MS_USER_RGN_ACSS> list) {
		final String deleteSQL = "delete from MS_USER_RGN_ACSS where WORKFORCE_MBR_ID=?";
		final String insertSQL = "insert into MS_USER_RGN_ACSS(WORKFORCE_MBR_ID, RGN_ABBR_NM, CREAT_TS) values(?,?,?)"; 
		
		if (list == null && list.size() == 0) {
			return false;
		}
		String id = list.get(0).getWORKFORCE_MBR_ID();
		System.out.println("WORKFORCE_MBR_ID::"+id);
		
		this.getJdbcTemplate().update(deleteSQL, new Object[]{id});
		
		for (int i = 0; i < list.size(); i++) {
			MS_USER_RGN_ACSS rgn = list.get(i);
			try {
				this.getJdbcTemplate().update(insertSQL, new Object[]{rgn.getWORKFORCE_MBR_ID(), rgn.getRGN_ABBR_NM(), rgn.getCREAT_TS()});
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
			
		}
		
		return true;
	}

	@Override
	public boolean editUserGeneralInfo(MS_USER_ADMIN user) {
		String sql = "UPDATE MS_USER_ADMIN SET "
				+ "USER_ADMIN_STA_CD = ?,"
				+ "USER_GRP_ID = ?,"
				+ "USER_STA_CD = ?,"
				+ "USER_TYPE_CD = ?,"
				+ "COST_CTR_CD = ?,"
				+ "DEPT_ID = ?,"
				+ "AMEX_BUS_CD = ?,"
				+ "USER_ACSS_TYPE_CD = ?,"
				+ "USER_ID = ?,"
				+ "USER_1ST_NM = ?,"
				+ "USER_MI_TX = ?,"
				+ "USER_LST_NM = ?," 
				+ "USER_EMAIL_AD_TX = ?,"
				+ "USER_CMPL_PHONE_NO = ?,"
				+ "WORKFORCE_MBR_MAN_1ST_NM = ?,"
				+ "WORKFORCE_MBR_MAN_MI_TX = ?,"
				+ "WORKFORCE_MBR_MAN_LST_NM = ?,"
				+ "WORKFORCE_MBR_MAN_EMAIL_AD_TX = ?,"
				+ "VP_NM = ?,"
				+ "ACSS_RSN_TX = ?,"
				+ "USER_ACSS_REJCT_RSN_TX = ?,"
				+ "WORKFORCE_MBR_CLASS_CD = ?,"
				+ "AMEX_UNIT_CD = ?,"
				+ "LST_LOGIN_TS = ?,"
				+ "CREAT_TS = ?,"
				+ "LST_UPDT_TS = ?,"
				+ "GEO_ACSS_LVL_CD = ?,"
				+ "LIF_GLBL_ACS_IN = ?,"
				+ "CLM_GLBL_ACS_IN = ? where WORKFORCE_MBR_ID = ?";
		Object[] params= {
				user.getUSER_ADMIN_STA_CD(),
				user.getUSER_GRP_ID(),
				user.getUSER_STA_CD(),
				user.getUSER_TYPE_CD(),
				user.getCOST_CTR_CD(),
				user.getDEPT_ID(),
				user.getAMEX_BUS_CD(),
				user.getUSER_ACSS_TYPE_CD(),
				user.getUSER_ID(),
				user.getUSER_1ST_NM(),
				user.getUSER_MI_TX(),
				user.getUSER_LST_NM(), 
				user.getUSER_EMAIL_AD_TX(),
				user.getUSER_CMPL_PHONE_NO(),
				user.getWORKFORCE_MBR_MAN_1ST_NM(),
				user.getWORKFORCE_MBR_MAN_MI_TX(),
				user.getWORKFORCE_MBR_MAN_LST_NM(),
				user.getWORKFORCE_MBR_MAN_EMAIL_AD_TX(),
				user.getVP_NM(),
				user.getACSS_RSN_TX(),
				user.getUSER_ACSS_REJCT_RSN_TX(),
				user.getWORKFORCE_MBR_CLASS_CD(),
				user.getAMEX_UNIT_CD(),
				user.getLST_LOGIN_TS(),
				user.getCREAT_TS(),
				user.getLST_UPDT_TS(),
				user.getGEO_ACSS_LVL_CD(),
				user.getLIF_GLBL_ACS_IN(),
				user.getCLM_GLBL_ACS_IN(),
				user.getWORKFORCE_MBR_ID()
		};
		
		return this.getJdbcTemplate().update(sql, params) > 0;
	}
}

